﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace Module
{
    public class SelectAll : DBInteractionBase
    {
        public DataTable SelectAllLoaiSanPham()
        {
            var dt = new DataSet();
            try
            {
                using (var dbcmd = new SqlCommand("DanhMucLoaiSanPham_Select", GetConnection()))
                {
                    dbcmd.CommandType = CommandType.StoredProcedure;
                    var dtAdapter = new SqlDataAdapter(dbcmd);
                    dtAdapter.Fill(dt);
                    return dt.Tables[0];
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DanhMucLoaiSanPham_Select: " + ex.Message);
            }
        }

        public DataTable SelectAllNhomSanPham()
        {
            var dt = new DataSet();
            try
            {
                using (var dbcmd = new SqlCommand("DanhMucNhomSanPham_Select", GetConnection()))
                {
                    dbcmd.CommandType = CommandType.StoredProcedure;
                    var dtAdapter = new SqlDataAdapter(dbcmd);
                    dtAdapter.Fill(dt);
                    return dt.Tables[0];
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DanhMucNhomSanPham_Select: " + ex.Message);
            }
        }

        public DataTable SelectAllNhomDichVu()
        {
            var dt = new DataSet();
            try
            {
                using (var dbcmd = new SqlCommand("DanhMucNhomDichVu_Select", GetConnection()))
                {
                    dbcmd.CommandType = CommandType.StoredProcedure;
                    var dtAdapter = new SqlDataAdapter(dbcmd);
                    dtAdapter.Fill(dt);
                    return dt.Tables[0];
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DanhMucNhomDichVu_Select: " + ex.Message);
            }
        }

        public DataTable SelectAllThue()
        {
            var dt = new DataSet();
            try
            {
                using (var dbcmd = new SqlCommand("DanhMucThue_Select", GetConnection()))
                {
                    dbcmd.CommandType = CommandType.StoredProcedure;
                    var dtAdapter = new SqlDataAdapter(dbcmd);
                    dtAdapter.Fill(dt);
                    return dt.Tables[0];
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DanhMucThue_Select: " + ex.Message);
            }
        }

        public DataTable SelectAllCuaHang()
        {
            var dt = new DataSet();
            try
            {
                using (var dbcmd = new SqlCommand("DanhMucCuaHang_Select", GetConnection()))
                {
                    dbcmd.CommandType = CommandType.StoredProcedure;
                    var dtAdapter = new SqlDataAdapter(dbcmd);
                    dtAdapter.Fill(dt);
                    return dt.Tables[0];
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DanhMucCuaHang_Select: " + ex.Message);
            }
        }

        public DataTable SelectAllChucVu()
        {
            var dt = new DataSet();
            try
            {
                using (var dbcmd = new SqlCommand("DanhMucChucVu_Select", GetConnection()))
                {
                    dbcmd.CommandType = CommandType.StoredProcedure;
                    var dtAdapter = new SqlDataAdapter(dbcmd);
                    dtAdapter.Fill(dt);
                    return dt.Tables[0];
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DanhMucChucVu_Select: " + ex.Message);
            }
        }
    }
}
